home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-11
/
trunc.zip
/
TRUNC.C
< prev
next >
Wrap
Text File
|
1993-04-10
|
2KB
|
64 lines
/******************************************************************************
TRUNC.C
Clipper floor & ceiling functions (also seems to fix Int() bugs).
1993 Evolution Software Systems
Compile using Microsoft C v7.0 as follows:
CL /c /FPa /Gh /AL /Zl /Oaltz /Ob1cegno /Gs /W3 /WX $*.c
FYI: "/Ob1cegno /Gs" is equivalent to "/Ox" except "/Ox" enables
"/Oi" which cannot be used with an alternate math library.
Requires LLIBCA.LIB to link
******************************************************************************/
#include <extend.h>
extern double ceil(double), floor( double ); // LLIBCA functions
/* MANUAL
*
* Floor() - truncate numeric value downwards to an integer
*
* Model: Floor( <nRealNum> ) --> nIntNum
*
* Args: <nRealNum> is any numeric value to trucate down.
*
* Use: This function is useful when a value has to be trucated downwards.
* If <nRealNum> is not an even integer, it is demoted to the next
* lowest integer. This should be identical to the Int() function
* which seems to malfunction at times.
*
* Note: Useful range is limited to C long (usuall approx. +- 2^31)
*/
CLIPPER Floor( void ) {
if ( ISNUM( 1 ) )
_retnl( (long) floor( _parnd( 1 ) ) );
}
/* MANUAL
*
* Ceiling() - truncate numeric value upwards to an integer
*
* Model: Ceiling( <nRealNum> ) --> nIntNum
*
* Args: <nRealNum> is any numeric value to trucate upwards.
*
* Use: This function is useful when a value has to be trucated upwards.
* If <nRealNum> is not an even integer, it is promoted to the next
* higher integer. This is similar to the Int() function which does
* not promote the number, but truncates it.
*
* Note: Useful range is limited to C long (usuall approx. +- 2^31)
*/
CLIPPER Ceiling( void ) {
if ( ISNUM( 1 ) )
_retnl( (long) ceil( _parnd( 1 ) ) );
}